/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

package com.facebook.imagepipeline.bitmaps;


import com.facebook.common.references.CloseableReference;
import ohos.media.image.PixelMap;
import ohos.media.image.common.PixelFormat;

/**
 * Bitmap factory for Gingerbread.
 */
public class GingerbreadBitmapFactory extends PlatformBitmapFactory {

    /**
     * Creates a bitmap of the specified width and height.
     *
     * @param width  the width of the bitmap
     * @param height the height of the bitmap
     *               Bitmap
     * @return a reference to the bitmap
     * @throws OutOfMemoryError if the Bitmap cannot be allocated
     */
    @Override
    public CloseableReference<PixelMap> createBitmapInternal(
            int width, int height, PixelFormat bitmapConfig) {
        PixelMap.InitializationOptions initializationOptions = new PixelMap.InitializationOptions();
        initializationOptions.pixelFormat = bitmapConfig;
        initializationOptions.size.width = width;
        initializationOptions.size.height = height;
        PixelMap bitmap = PixelMap.create(initializationOptions);
        return CloseableReference.of(bitmap, SimpleBitmapReleaser.getInstance());
    }
}
